package com.winner.rabbitmq.controller;

import com.winner.rabbitmq.rabbitmq.FirstSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * 测试rabbitMq发送信息, 并被consumer消费
 * 在真实的微服务项目里， 发送在一个微服务， 消费在另一个微服务里。  比如用户销户发送mq  解析安装包发送mq
 * https://blog.csdn.net/qq_38455201/article/details/80308771
 *
 */
@RestController
@RequestMapping("/rabbitmq")
public class SendController {

    @Autowired
    private FirstSender firstSender;

    /**
     * localhost:8080/rabbitmq/send/你好
     */
    @GetMapping("/send/{message}")
    public String send(@PathVariable String message){
        String uuid = UUID.randomUUID().toString();
        firstSender.send(uuid,message);
        return uuid;
    }
}
